//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.jpgolay.me.export;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.*;
import org.jpgolay.gui.fixed.*;
import org.jpgolay.gui.iconBar.IconBar;

public class ExportGUI extends JInternalFrame {

    public ExportGUI() {
        jContentPane = null;
        iconBar = null;
        basicMenu = null;
        mainPanel = null;
        piecesLabelAndComboBox = null;
        exportOnLabelAndComboBox = null;
        fileNameLabelAndTextField = null;
        periodLabelAndDateButton = null;
        initialize();
    }

    private void initialize() {
        setJMenuBar(getBasicMenu());
        setFrameIcon(new ImageIcon(getClass().getResource("/org/jpgolay/gui/images/arrowRight18x18.png")));
        setTitle("EXPORTER");
        setSize(330, 194);
        setContentPane(getJContentPane());
    }

    private JPanel getJContentPane() {
        if (jContentPane == null) {
            jContentPane = new JPanel();
            jContentPane.setLayout(new BorderLayout());
            jContentPane.add(getIconBar(), "North");
            jContentPane.add(getMainPanel(), "Center");
        }
        return jContentPane;
    }

    private IconBar getIconBar() {
        if (iconBar == null) {
            iconBar = new IconBar();
        }
        return iconBar;
    }

    private BasicMenu getBasicMenu() {
        if (basicMenu == null) {
            basicMenu = new BasicMenu();
        }
        return basicMenu;
    }

    private JPanel getMainPanel() {
        if (mainPanel == null) {
            FlowLayout flowLayout1 = new FlowLayout();
            mainPanel = new JPanel();
            mainPanel.setLayout(flowLayout1);
            mainPanel.add(getPeriodLabelAndDateButton(), null);
            mainPanel.add(getPiecesLabelAndComboBox(), null);
            mainPanel.add(getExportOnLabelAndComboBox(), null);
            mainPanel.add(getFileNameLabelAndTextField(), null);
            flowLayout1.setVgap(2);
        }
        return mainPanel;
    }

    private LabelAndComboBox getPiecesLabelAndComboBox() {
        if (piecesLabelAndComboBox == null) {
            piecesLabelAndComboBox = new LabelAndComboBox();
            piecesLabelAndComboBox.setLabel("Pi\350ce");
            piecesLabelAndComboBox.setList(new String[]{
                        "FACTURES CLIENT", "FACTURES FOURNISSEURS"
                    });
        }
        return piecesLabelAndComboBox;
    }

    private LabelAndComboBox getExportOnLabelAndComboBox() {
        if (exportOnLabelAndComboBox == null) {
            exportOnLabelAndComboBox = new LabelAndComboBox();
            exportOnLabelAndComboBox.setLabel("Exporter au format");
            exportOnLabelAndComboBox.setList(new String[]{
                        "EBP", "CIEL", "API SOFT", "CEGID", "SARI"
                    });
        }
        return exportOnLabelAndComboBox;
    }

    private LabelAndTextField getFileNameLabelAndTextField() {
        if (fileNameLabelAndTextField == null) {
            fileNameLabelAndTextField = new LabelAndTextField();
            fileNameLabelAndTextField.setLabel("Nom du fichier");
        }
        return fileNameLabelAndTextField;
    }

    private LabelAndDateButton getPeriodLabelAndDateButton() {
        if (periodLabelAndDateButton == null) {
            periodLabelAndDateButton = new LabelAndDateButton();
            periodLabelAndDateButton.setLabelLeft("P\351riode");
        }
        return periodLabelAndDateButton;
    }

    public BasicMenu getMenuPanel() {
        return getBasicMenu();
    }

    public IconBar getIconBarPanel() {
        return getIconBar();
    }

    public LabelAndComboBox getPieces() {
        return getPiecesLabelAndComboBox();
    }

    public LabelAndComboBox getExportOn() {
        return getExportOnLabelAndComboBox();
    }

    public LabelAndTextField getFileName() {
        return getFileNameLabelAndTextField();
    }

    public LabelAndDateButton getPeriod() {
        return getPeriodLabelAndDateButton();
    }
    private JPanel jContentPane;
    private IconBar iconBar;
    private BasicMenu basicMenu;
    private JPanel mainPanel;
    private LabelAndComboBox piecesLabelAndComboBox;
    private LabelAndComboBox exportOnLabelAndComboBox;
    private LabelAndTextField fileNameLabelAndTextField;
    private LabelAndDateButton periodLabelAndDateButton;
}
